package xiaohu.day2.HJ27;

import java.util.*;

public class Main {
    public static void main(String[] args) {






        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String[] str = in.nextLine().split(" ");
            int n = Integer.parseInt(str[0]);
            int k = Integer.parseInt(str[str.length-1]);
            String key= str[str.length-2];
            HashMap<Character, Integer> map = new HashMap<>();
            for (int i = 0; i < key.length(); i++) {
                if (map.containsKey(key.charAt(i))) {
                    map.put(key.charAt(i), map.get(key.charAt(i)) + 1);
                } else {
                    map.put(key.charAt(i), 1);
                }
            }
            ArrayList<String> stringList = new ArrayList<>();
            for (int i = 1; i < str.length - 2; i++) {
                HashMap<Character, Integer> hashMap = new HashMap<>();
                String strTemp = str[i];
                for (int j = 0; j < strTemp.length(); j++) {
                    char charAt = strTemp.charAt(j);
                    if (hashMap.containsKey(charAt)) {
                        hashMap.put(charAt, hashMap.get(charAt) + 1);
                    } else {
                        hashMap.put(charAt, 1);
                    }
                }
                if (hashMap.equals(map) && !key.equals(str[i])) {
                    stringList.add(str[i]);
                }
            }
            Collections.sort(stringList);
            System.out.println(stringList.size());
            if (stringList.size()>k) {
                System.out.println(stringList.get(k-1));
            }
        }
    }
}
